export class Result {
  code: number
  data?: any
  timestamp: Date

  constructor(code: number, data?: any) {
    this.code = code
    this.data = data
    this.timestamp = new Date()
  }

  /**
   * 成功
   * @param data
   * @param code
   */
  static success(data: any, code = 200) {
    return new Result(code, data)
  }

  /**
   * 失败
   * @param code
   * @param data
   */
  static fail(code, data?: any) {
    return new Result(code, data)
  }
}
